/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package holdem.pokergui;

import holdem.Card;
import java.util.ArrayList;
import java.util.Random;

/**
 *
 * @author Anders
 */
public class CardDeck
{
    private ArrayList<MyCard> allCards = new ArrayList<MyCard>();
    private Random rand = new Random();

    public CardDeck()
    {
        for (int i = 0; i <= GuiCard.CLUBS; i++)
	    for (int j = 1; j <= GuiCard.KING; j++)
                allCards.add(new MyCard(new Card(Card.Suite.dimond,i)));
    }


    public MyCard takeCard()
    {
	if (allCards.isEmpty())
	    return null;
	int nr = rand.nextInt(allCards.size());
	return allCards.remove(nr);
    }

    public boolean isEmpty(){
	return allCards.isEmpty();
    }

    public ArrayList<MyCard> cards()
    {
        return allCards;
    }

    public void shuffle()
    {
        //logic
    }

    public void cardToPlayers(Player[] players)
    {
        
        for(int i = 0; i < 2; i++)
            for(int j = 0; j < players.length; j++)
            {
                if (players[j] != null)
                {
                    MyCard[] tmp = players[j].getHand();
                    tmp[i] = takeCard();
                    players[j].setHand(tmp);
                }
            }
    }
}